<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<link rel="stylesheet"
			href="${pageContext.request.contextPath}/css/base.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath}/css/info-reg.css" />
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/jquery.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/common.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/js/WdatePicker.js"></script>
		<title>添加公共资源</title>
	</head>
	<body>
		<form action="${pageContext.request.contextPath}/ComMethod.action?method=updateCom"
			method="post">
			<div class="title">
				<h2>
					信息登记
				</h2>
			</div>
			<div class="main">
				<p class="long-input ue-clear">
					<label>
						物品id：
					</label>
					<input type="text" placeholder="物品编号" id="id" name="id"
						value="${requestScope.combyid.crId }" readonly="readonly"/>
				</p>
				<p class="long-input ue-clear">
					<label>
						物品名称：
					</label>
					<input type="text" placeholder="物品名称" id="name" name="name"
						value="${requestScope.combyid.crName }" />
				</p>
				<p class="long-input ue-clear">
					<label>
						物品价格：
					</label>
					<input type="text" placeholder="请输入编号" id="price" name="price"
						value="${requestScope.combyid.crPrice }" />
				</p>
				<div class="short-input select ue-clear">
					<label>
						状态：
					</label>
					<div class="select-wrap">
						<input type="radio" name="status" value="fine" id="condition1">
						正常
						<input type="radio" name="status" value="unfine" id="condition2" />
						维护
					</div>
				</div>
				<p class="long-input ue-clear">
					<label>
						物品数量：
					</label>
					<input type="text" placeholder="请输入数量" id="num" name="num"
						value="${requestScope.combyid.crNum }" />
				</p>
			</div>
			<div class="btn ue-clear">
				<input type="button" value="确认" onclick="update()"/>
				<input type="button" value="返回" onclick="upback()"/>
			</div>
		</form>
	</body>
	<script type="text/javascript">
	function upback() {
		var url = "${pageContext.request.contextPath }/ComMethod.action?method=selectCom";
		url += '&currPage=' + '${requestScope.page }';
		url += '&name=' + '${requestScope.select.name }';
		url += '&minprice=' + '${requestScope.select.minprice }';
		url += '&maxprice=' + '${requestScope.select.maxprice }';
		url += '&maxnum=' + '${requestScope.select.maxnum }';
		url += '&minnum=' + '${requestScope.select.minnum }';
		url += '&status=' + '${requestScope.select.condition }';
		window.location.href = url;
	}
	function update(){
		var url = "${pageContext.request.contextPath }/ComMethod.action?method=updateCom";
		url += '&currPage=' + '${requestScope.page }';
		url += '&name=' + '${requestScope.select.name }';
		url += '&minprice=' + '${requestScope.select.minprice }';
		url += '&maxprice=' + '${requestScope.select.maxprice }';
		url += '&maxnum=' + '${requestScope.select.maxnum }';
		url += '&minnum=' + '${requestScope.select.minnum }';
		url += '&status=' + '${requestScope.select.condition }';
		url += '&newname=' + document.getElementById("name").value;
		url += '&price=' + document.getElementById("price").value;
		if($('#condition1').attr('checked')){
			url += '&condition='+"fine";
		}else{
			url += '&condition='+"unfine";
		}
		url += '&num=' + document.getElementById("num").value;
		url += '&id=' + document.getElementById("id").value;

		window.location.href = url;
	}
	window.onload = function() {
		if ('${requestScope.combyid.crCondition}' == "正常") {
			$('#condition1').attr('checked', 'checked');
		} else {
			$('#condition2').attr('checked', 'checked');
		}
	}
</script>
</html>
